package jUnit_tests;

import static org.junit.Assert.*;

import java.util.Date;

import model.*;

import org.junit.Before;
import org.junit.Test;

import controller.ACSystem;
/**
 * 
 * @author Kevin Smith
 * @author Bob Landowski
 *
 */
public class File_IO_tests {
	
	/*GLOBALS*/
	//AuctionCalendar ac = new AuctionCalendar();
	ACSystem evil_overlord;
	ACDirector acdirector; //
	Address addr1; //
	Address addr2; //
	Address addr3; //
	Auction auc1; //
	Auction auc2; //
	Auction auc3; //
	AuctionCentralEmployee acemployee; //
	Bidder bidder; //
	CreditCard cc; // added to bidder
	Item item1; // 1
	Item item2; // 1
	Item item3; // 2
	NonProfit np; //
	NonProfit np2; //
	NonProfit np3; //
	NonProfit np4;
	TimeObject to1; // 8am 4 hours
	TimeObject to2; // 3:30 pm 2 hours
	Date d1; // Mar 15 2014
	Date d2; // Apr 1 2014
	Date d3; // Apr 2 2014
	

	@SuppressWarnings("deprecation")
	@Before
	public void setUp() throws Exception {
		evil_overlord = new ACSystem();
		to1 = new TimeObject(8, 0, 4);
		to2 = new TimeObject(15, 30, 2);
		//           year, month, day
		d1 = new Date(114, 2, 25);
		d2 = new Date(114, 3, 1);
		d3 = new Date(114, 3, 1);
		addr1 = new Address("123 Street st", "", "303", "Tacoma", "WA", "98402");
		addr2 = new Address("222 Notareal Ave", "Attn: Auction Dept.", "", "Hobbiton", "TS", "11111");
		addr3 = new Address("333 Three St", "Threeee", "333", "Threeville", "TH", "33333");
		acdirector = new ACDirector("Mr.", "Director", "director", "password", "1234567890", addr1,
				"joe@joe.co", "666");
		acemployee = new AuctionCentralEmployee("Little", "Peon", "employee", "password", 
				"1231231234", addr1, "ima@hotmail.com", "999");
		bidder = new Bidder("John", "Doe", "bidder", "password", "1112223333", addr3, "jondo@gm.com");
		np = new NonProfit("Melba", "Peachbottom", "peachpi", "password", "4445554444", addr2, 
				"peachykeen@mail.net", "San Diego Historical Society");
		np2 = new NonProfit("Julie", "Copper", "jcopper", "password", "4449554444", addr2, 
				"peachyplease@mail.net", "Spanish Name Historical Society");
		np3 = new NonProfit("Marge", "McGee", "nonprofff", "password", "4445554449", addr2, 
				"peachfuzz@mail.net", "Los Angeles Historical Society");
		np4 = new NonProfit("Eric", "Struck", "nonprofit", "password", "4445551111", addr2, 
				"woohoooo@mail.net", "San Jose Historical Society");
		evil_overlord.addUser(acdirector);
		evil_overlord.addUser(acemployee);
		evil_overlord.addUser(bidder);
		evil_overlord.addUser(np);
		evil_overlord.addUser(np2);
		evil_overlord.addUser(np3);
		evil_overlord.addUser(np4);
		cc = new CreditCard("1234123412341234", 2015, 11, "123");
		bidder.addCreditCard(cc);
		auc1 = new Auction(d1, to1, 2, 125, np);
		auc2 = new Auction(d2, to1, 2, 125, np2);
		auc3 = new Auction(d3, to2, 2, 100, np3);
		evil_overlord.getAuctionCalendar().addAuction(auc1);
		evil_overlord.getAuctionCalendar().addAuction(auc2);
		evil_overlord.getAuctionCalendar().addAuction(auc3);
		item1 = new Item(auc1, "auction one item", "photooooo", 1);
		item2 = new Item(auc1, "auction one item 2", "photo", 1);
		item3 = new Item(auc2, "auction two item", "phooo", 1);
		auc1.addItem(item1);
		auc1.addItem(item2);
		auc2.addItem(item3);
		Bid bid1 = new Bid(item1,bidder,1.00);
		Bid bid2 = new Bid(item2,bidder,15.95);
		Bid bid3 = new Bid(item3,bidder,9.50);
		bidder.placeBid(bid1);
		bidder.placeBid(bid2);
		bidder.placeBid(bid3);

	}

	@Test
	/**
	 * Tests all of the File write functions in the ACSystem class.  Must be
	 * verified visually!
	 */
	public void test() {
		evil_overlord.write();
		
	}
	
	@Test
	public void testFindItem() {
		assertEquals("", evil_overlord.getAuctionCalendar().findItem(100001).toString(), 
				item2.toString());
	}
	
	@Test
	public void testFindAuction() {
		assertEquals("", evil_overlord.getAuctionCalendar().findAuction(
				"San-Diego-Historical-Society-3-25-2014").toString(), auc1.toString());
	}
	
/*	@Test
	public void testTimeObjectErrorBox() {
		TimeObject to3 = new TimeObject(23,50, 5);
	} */

}
